home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11488 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: jitter.larc.nasa.gov!lance
  2. From: lance@jitter.larc.nasa.gov (Michael Lance)
  3. Newsgroups: comp.lang.c++
  4. Subject: Explicit copy constructor calls illegal?
  5. Date: 14 Mar 1996 19:58:32 GMT
  6. Organization: nasa
  7. Sender: lance@jitter.larc.nasa.gov ()
  8. Distribution: world
  9. Message-ID: <4i9tp8$fgt@reznor.larc.nasa.gov>
  10. NNTP-Posting-Host: jitter.larc.nasa.gov
  11.  
  12. Hey!
  13.  
  14. I am not a C++ newbie, but am feeling like I missed something:
  15.  
  16. Why can I not make an explicit call to a copy constructor from a class
  17. member function?  To define my terminology, the copy constructor is the
  18. function:
  19.                 MyClass(const MyClass&)
  20.  
  21. When I try to do this (just trying to re-use code - it is there, why not?),
  22. a new instance of the class is instantiated SOMEWHERE, but a cout in the
  23. constructor does NOT reflect it.  The copy constructor properly assigns
  24. the member variables of the instance, and the destructor registers its
  25. destruction!
  26.  
  27. Any clues, or am I violating a basic tenet?  Lippman 2nd. edition is no
  28. help here.  
  29.  
  30. By the way, I am using an old version of g++ - 2.6.2, I think, on an
  31. HP running HP-UX 9.0.5.
  32.  
  33. Michael B. Lance
  34. Lockheed Engineering & Sciences
  35. Hampton, Virginia
  36.